Passed
Pull Request — master (#2)
by
unknown
03:05
created

router.js ➔ ... ➔ ???   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5.2742

Importance

Changes 3
Bugs 0 Features 2
Metric Value
cc 5
nc 9
nop 2
dl 0
loc 21
ccs 7
cts 9
cp 0.7778
crap 5.2742
rs 8.9093
c 3
b 0
f 2
1
/**
2
 * @method setup
3
 * @param  {Function}   setTitle    setTitle callback
4
 * @param  {Object}     options     { router: RouterInstance }
0 ignored issues
show
Documentation introduced by
The parameter options does not exist. Did you maybe forget to remove this comment?
Loading history...
5
 * @return {void}
6
 */
7 2
const setup = (setTitle, setPrefix, setSuffix, { router }) => {
8 1
  router.afterEach((to, from) => {
0 ignored issues
show
Unused Code introduced by
The parameter from is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
9 2
    const { meta } = to
10
11
    // if has meta
12 2
    if (meta) {
13
      // if has title
14 2
      if (meta.title) {
15 1
        setTitle(meta.title)
16
      }
17
18
      // if has titlePrefix
19 2
      if (meta.titlePrefix) {
20
        setPrefix(meta.titlePrefix)
21
      }
22
23
      // if has titleSuffix
24 2
      if (meta.titleSuffix) {
25
        setSuffix(meta.titleSuffix)
26
      }
27
    }
28
  })
29
}
30
31
export { setup }
32